# class TreeNode:
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None

#
#
# @param root TreeNode类
# @return int整型二维数组
#
class Solution:
    def zigzagLevelOrder(self, root):
        # write code here
        if not root: return
        cur = [root]
        res = []
        count = 0
        while cur:
            resLite = []
            nex = []
            count += 1
            for node in cur:
                if node.left: nex.append(node.left)
                if node.right: nex.append(node.right)
                resLite.append(node.val)
            if count % 2:
                res.append(resLite)
            else:
                res.append(resLite[::-1])
            cur = nex
        return res

